#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QToolBar>
#include <QMenuBar>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //工具栏就不会在ui文件自动生成了，需要创建
    QToolBar* tool = new QToolBar();
    addToolBar(tool);

    QAction* a = new QAction("保存");
    QAction* b = new QAction("打开");
    tool->addAction(a);
    a->setToolTip("保存文件");
    tool->addAction(b);

    QMenuBar* menubar = this->menuBar();
    setMenuBar(menubar);

    QMenu* menu = new QMenu("文件");
    menubar->addMenu(menu);

    menu->addAction(a);
    menu->addAction(b);

}

MainWindow::~MainWindow()
{
    delete ui;
}

